﻿Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports I_PORT.DB_Class

' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class TruckScale
    Inherits System.Web.Services.WebService
    ''' <summary>
    ''' For insert truck scale data to database.
    ''' </summary>
    ''' <param name="Modify_Flag">A single character for modify flag.(C=Create,M=Modify,D=Delete)</param>
    ''' <param name="Type_Name">Name of ship.</param>
    ''' <param name="Booking_no">Booking No.</param>
    ''' <param name="Scale_Order_IN">Order to scale in.</param>
    ''' <param name="Weight_IN"></param>
    ''' <param name="Scale_Order_OUT">Order to scale out.</param>
    ''' <param name="Weight_OUT"></param>
    ''' <param name="Net_Weight"></param>
    ''' <param name="Transport_Company"></param>
    ''' <param name="Date_Scale_IN"></param>
    ''' <param name="Time_Scale_IN"></param>
    ''' <param name="Date_Scale_OUT"></param>
    ''' <param name="Time_Scale_OUT"></param>
    ''' <param name="Truck_Licence"></param>
    ''' <param name="Trailer_Licence"></param>
    ''' <param name="Item_No"></param>
    ''' <param name="Order_No"></param>
    ''' <param name="Product_no"></param>
    ''' <param name="Lot_no"></param>
    ''' <param name="Product_Weight"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    <WebMethod()> _
     Public Function InsertTruckScale(ByVal Modify_Flag As String _
                                     , ByVal Type_Name As String _
                                     , ByVal Booking_no As String _
                                     , ByVal Scale_Order_IN As String, ByVal Weight_IN As String _
                                     , ByVal Scale_Order_OUT As String, ByVal Weight_OUT As String _
                                     , ByVal Net_Weight As String _
                                     , ByVal Transport_Company As String _
                                     , ByVal Date_Scale_IN As String, ByVal Time_Scale_IN As String _
                                     , ByVal Date_Scale_OUT As String, ByVal Time_Scale_OUT As String _
                                     , ByVal Truck_Licence As String, ByVal Trailer_Licence As String _
                                     , ByVal Item_No As String, ByVal Order_No As String _
                                     , ByVal Product_no As String _
                                     , ByVal Lot_no As String _
                                     , ByVal Product_Weight As String _
                                     ) As String
        Dim db As DB_Class = New DB_Class("IPORT")
        ' db.connectionStringName = "IPORT"
        Dim ret As String = ""
        Dim TruckScaleID As String = db.GeneratID("Truck_Scale", "TruckScaleID")
        Dim ins As String = "insert into Truck_Scale " & _
        "(TruckScaleID,Modify_Flag,Type_Name,Booking_no,Scale_Order_IN,Weight_IN,Scale_Order_OUT,Weight_OUT,Net_Weight,Transport_Company" & _
        ",Date_Scale_IN,Time_Scale_IN,Date_Scale_OUT,Time_Scale_OUT,Truck_Licence,Trailer_Licence,Item_No,Order_No,Product_no,Lot_No,Product_Weight)"
        ins &= String.Format(" values('{0}','{1}','{2}','{3}',{4},{5},{6},{7},{8},'{9}','{10}','{11}','{12}','{13}','{14}','{15}',{16},'{17}','{18}','{19}',{20})" _
        , TruckScaleID, Modify_Flag, Type_Name, Booking_no, Scale_Order_IN, Weight_IN, Scale_Order_OUT, Weight_OUT, Net_Weight _
        , Transport_Company, Date_Scale_IN, Time_Scale_IN, Date_Scale_OUT, Time_Scale_OUT, Truck_Licence, Trailer_Licence, Item_No, Order_No _
        , Product_no, Lot_no, Product_Weight _
        )
        db.queryString = ins
        ret = db.insertUpdate()
        Return ret
    End Function
    <WebMethod()> _
    Public Function GetTruckScale() As DataTable
        Dim db As DB_Class = New DB_Class("IPORT")
        db.queryString = "select * from Truck_Scale"
        Dim dt As DataTable = db.getTable("truckScale")
        Return dt
    End Function
End Class